let App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    userId: '',
    details: {},
    showModalStatus2: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let userId = wx.getStorageSync("userId");
    this.setData({
      id: options.id,
      userId: userId
    });
    this.activityDetail();
    wx.showShareMenu({
      // 要求小程序返回分享目标信息
      withShareTicket: true
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  // 获取活动详情信息
  activityDetail() {
    let id = this.data.id;
    App.HttpService.getActivityDetail({
      id
    }).then(res => {
      if (res.data.code == 200) {
        let data = res.data.data;
        this.setData({
          details: data
        });
      }
    });
  },
  onShareAppMessage: function(e) {
    let type = e.target.dataset.type
    let userId = wx.getStorageSync('userId');
    return {
      title: '扳子养车',
      path: `pages/index/index?userId=${userId}`
    }
  },
  setModalStatus3(e) {
   
    // let { status, index } = e.currentTarget.dataset
    let status = 0;
    this.setData({
      status
    });
    let animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData2: animation.export()
    })
    if (status == 0) {
      this.setData({
        showModalStatus2: false
      })
    }
    setTimeout(function() {
      animation.translateY(0).step()
      this.setData({
        animationData2: animation
      })
      if (status == 0) {
        this.setData({
          showModalStatus2: false
        })
      }
    }.bind(this), 100)

  },
  setModalStatus2(e) {
    var url = e.currentTarget.dataset.url
    var type = e.currentTarget.dataset.status
    if (type == 0) {

     
        let status = !this.data.status;
        this.setData({
          status
        });
        let animation = wx.createAnimation({
          duration: 200,
          timingFunction: "linear",
          delay: 0
        })
        this.animation = animation
        animation.translateY(300).step()
        this.setData({
          animationData2: animation.export()
        })
        if (status == 1) {
          this.setData({
            showModalStatus2: true
          })
        }
        setTimeout(function() {
          animation.translateY(0).step()
          this.setData({
            animationData2: animation
          })
          if (status == 0) {
            this.setData({
              showModalStatus2: false
            })
          }
        }.bind(this), 100)
      
    } else {
      
      if (url) {
        wx.navigateTo({
          url: url,
        })
      }

    }

  }

})